package applicationRunner;

import gui.MainGUI;

import java.lang.reflect.Field;

public class Home_Sim {

	public static void main(String args[]) {
		try {
			setLibraryPath();
		} catch (Exception e) {
			System.err
					.println("Cannot set library path - please set VM arguments to -Djava.library.path=lib");
		}
		MainGUI m;
		if (args.length == 1) {
			if (args[0].equalsIgnoreCase("test"))
				;
			MainGUI.testMode = true;
			m = new MainGUI();
			m.setVisible(true);
			MainGUI.loadTestData();
		} else {
			MainGUI.testMode = false;
			m = new MainGUI();
			m.setVisible(true);
		}
	}

	private static void setLibraryPath() {
		System.setProperty("java.library.path", "lib");
		System.out.println(System.getProperty("java.library.path"));
		Field fieldSysPath;
		try {
			fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
			fieldSysPath.setAccessible(true);
			fieldSysPath.set(null, null);
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchFieldException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
